library(tidyverse)
## -- Attaching packages -------------- tidyverse 1.3.0 --
## v ggplot2 3.2.1 v purrr 0.3.3
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts ----------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
SNPs<- read.table("23andMe_complete.txt", header = TRUE, sep = "\t")
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1,22),"X","Y","MT"))
ggplot(SNPs, aes(SNPs$chromosome, fill=SNPs$chromosome))+
geom_bar(fill="blue")+
ggtitle("Genotype Counts per Chromsome")+
scale_x_discrete("Chromosome")+
scale_y_continuous("Number of SNPs")
mycolor<- c("AA"="blue", "AC"="blue", "AG"="blue", "AT"="blue","CC"="blue", "CG"="blue", "CT"="blue", "GG"="blue","GT"="blue", "TT"="blue", "A"="red", "C"="red","G"="red", "T"="red", "D"="green", "DD"="green", "DI"="green", "I"="green", "II"="green", "--"="green")
ggplot(SNPs, aes(SNPs$chromosome, fill=genotype))+
geom_bar()+
ggtitle("Genotype Counts per Chromosome")+
scale_x_discrete("Chromosome")+
scale_y_continuous("Number of SNPs")+
scale_fill_manual(values=mycolor)
Genotype counts per chromosome
sp<- ggplot(SNPs, aes(SNPs$chromosome, fill=genotype))+
geom_bar(position="dodge")+
facet_wrap(~genotype, ncol = 2)+
ggtitle("Genotype Counts per Chromosome")+
scale_x_discrete("Chromosome")+
scale_y_continuous("Number of SNPs")+
theme(axis.text.x = element_text(angle=90, size=7),
legend.position = "none")
sp
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(sp)
library(DT)
y<- subset(SNPs, chromosome=='Y')
datatable(y)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html